<%--
 *  File:    ProtocolType.jsp
 *  @Author: banshang	
 *  Date:    2010/07/20
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>


<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "DMS";
 	String strTableName = "v_protocoltype";
	String privilegeCode = "11202";    
    String contextPath = request.getContextPath(); 
    String languagecode = (String)session.getAttribute("languagecode");
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>ProtocolType</title>
<PageFlow:CheckPageFlow pageName="p_protocoltype"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
  	if(totalsummary == null)
  	{
  		totalsummary = new Vector();
  	}
    Integer dep = (Integer)pageContext.getAttribute("dep");
    if(dep == null) dep= new Integer(-2);

%>

<script language="JavaScript" >
function page_summary(){

 	  var link = "ProtocolType.jsp?<%= OvalTools.randomURL() %>&dep="+cform.dep.value;
      self.location.href = link;
}

function page_add(){


	   if(cform.department.value=="")
			{
				alert("<%= message.getMessageDesc("PLEASE_SELECT_DEPARTMENT") %>");
				return;
			}
	  
	  if(cform.protocolname.value=="")
			{
				alert("<%= message.getMessageDesc("TYPE_NAME_NOT_NULL") %>");
				return;
			}

	 formatCheckBox(cform);
	 if(!checkForm(cform)) return;
     cform.actionname.value = "add";
  	 cform.target = "_self";
  	 isRunning = true;
  	 cform.submit();
}

function page_delete(){
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}

function setCommand(){
	var checked = document.cform.threepart.checked;
	
	if(checked){
		document.cform.thirdcustomertype.command='notnull';
	}else{
		document.cform.thirdcustomertype.command='';
	}
}
</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher">
<input type="hidden" name="pagename" value="p_protocoltype">
<input type="hidden" name="actionname">
<custom:hidden name="userinfo" property="orgid" scope="session"/>
<custom:hidden name="userinfo" property="userid" changedName="maker" scope="session"/>
<%@ include file="/inc/PageLocation.inc" %>

<table width="100%" border="0" cellspacing="0">
   <tr>
   	<td width="200">
   	   <%= label.getLabelName("L_Dept")+ label.getLabelName("L_Colon") %>
   	   
   	   <custom:select property="dep" optionInnerTextKey="deptname" optionsName="alldepts" optionValueKey="deptid" defaultValue="-------" defaultValueCost=" " label="L_Dept"/>
   	  
   	   <a href="javascript:page_summary('search')"><img src="<%= contextPath %>/images/<%=languagecode %>/go_fy.gif" border="0" style="border: 1 solid #000000"></a>
   	</td>
   </tr>
   <tr>
     <td class="summary_top"></td>
   </tr>
</table>
<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <tr class="deepblue-left" >
		  <td class="title_center" width="22">&nbsp;</td>
          <td class="title_center" width="*"><%= label.getLabelName("L_Type")+label.getLabelName("L_Name") %> <span class="red">*</span> </td>
          <td class="title_center" width="10%"><%= label.getLabelName("L_Dept") %>&nbsp;</td>
          <td class="title_center" width="10%"><%= label.getLabelName("L_IsProxy") %>&nbsp;</td>
          <td class="title_center" width="10%"><%= label.getLabelName("L_ThreePart") %></td>
          <td class="title_center" width="10%"><%= label.getLabelName("L_FirstOrg") %><%= label.getLabelName("L_CustomerType") %></td>
          <td class="title_center" width="10%"><%= label.getLabelName("L_SecondOrg") %><%= label.getLabelName("L_CustomerType") %></td>
          <td class="title_center" width="10%"><%= label.getLabelName("L_ThirdOrg") %><%= label.getLabelName("L_CustomerType") %></td>
        </tr>
		 <% //--------------------------------------  default value definition --%>
          	<%
            	int i = 0;
             	String strClassType = new String();
          	%>

          	<% //--------------------------------------  loop results --%>
		<logic:iterate id="onerow" collection="<%= totalsummary %>" indexId="idx">
           	<%
            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
            	if(i%2 == 1)
            	{
              		strClassType = "td-listrom";
            	}else{
              		strClassType = "";
            	}
            	i++;
          	%>
          	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  class="none">
          		<td width="5" class="title_center">
              		<input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull( tempMap.get("protocoltypeid") )%>" class="checkbox">
            	</td>
            	<td class="title_center">
            		<custom:write name="onerow" property="protocolname" nbsp="true"/>
            	</td>
            	<td class="title_center">
            		<custom:write name="onerow" property="deptname"  nbsp="true"/>
            	</td>
				<td class="title_center">
					<custom:checkbox  name="onerow" property="agency" style="border:0" checkFlag="Y/N" disabled="true" colIndex="<%= idx %>"/>
				</td>    
				<td class="title_center">
					<custom:checkbox  name="onerow" property="threepart" style="border:0" checkFlag="Y/N" disabled="true" colIndex="<%= idx %>"/>
				</td> 
				<td class="title_center">
					<custom:write name="onerow" property="firstcustomertype" dictType="GlobalPCCode" nbsp="true"/>
				</td>
				<td class="title_center">
					<custom:write name="onerow" property="secondcustomertype" dictType="GlobalPCCode" nbsp="true"/>
				</td>
				<td class="title_center">
					<custom:write name="onerow" property="thirdcustomertype" dictType="GlobalPCCode" nbsp="true"/>
				</td>
     		 </tr>
     	 </logic:iterate>
 <%if(dep.toString().equals("-1")){  %>  
  <% }else{%> 
      <tr class="none">
            <td class="title_center">&nbsp;</td>
            <td class="title_center">
            	<custom:text name="newdetail" property="protocolname" style="width=200" style="border:1px #7F9DB9 solid; width:200px;"/>
			</td>
            <td class="title_center">
            	<custom:write  property=""  nbsp="true"/>
            	<custom:hidden  property="department" />
            </td>
            <td class="title_center">
            	<custom:checkbox  name="newdetail" property="agency" style="border:0" checkFlag="Y/N" />
            </td>
            <td class="title_center">
            	<custom:checkbox  name="newdetail" property="threepart" style="border:0" checkFlag="Y/N" onclick="setCommand()"/>
            </td>
            <td class="title_center">
            	<custom:selectdic dictType="GlobalPCCode" property="firstcustomertype"/>
            </td>
            <td class="title_center">
            	<custom:selectdic dictType="GlobalPCCode" property="secondcustomertype"/>
            </td>
            <td class="title_center">
            	<custom:selectdic dictType="GlobalPCCode" property="thirdcustomertype" command="" defaultValue="---------" defaultValueCost="" label="L_ThirdCustomerType"/>
            </td>
      </tr>
     <%} %>
 </table>     
  <%if(dep.toString().equals("-1")){  %>  
  <% }else{%> 
     <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td class="summary_top"></td>
        </tr>
        <tr>
          <td class="td_center">
		  	<a onclick="page_add()"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60"/></a>
		  <%if(totalsummary.size() >0 ){%>
		  	<a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
		  <%} %>
		  </td>
        </tr>
     </table>
   <%} %>
</table>
</form>
</body>
</html>